#if !defined(CUSTOM_MENU_MANAGER_H)
#define CUSTOM_MENU_MANAGER_H

#include "..\client\Util.h"
#include "..\client\Singleton.h"
#include "..\client\SettingsManager.h"

class CustomMenuItem
{
	typedef CustomMenuItem* Ptr;
public:
	CustomMenuItem(
			int p_type, int p_id, string const& p_title
			): m_type(p_type), m_id(p_id), m_title(p_title){}
	CustomMenuItem( const CustomMenuItem* p_src):
			m_id(p_src->getID()), m_title(p_src->getTitle()),  m_type(p_src->getType()) { }
public:
	GETSET(int, m_id, ID);
	GETSET(string, m_title, Title);
	GETSET(int, m_type, Type);
};

class CustomMenuManager
	: public Singleton<CustomMenuManager>, private SettingsManagerListener
{
public:
    
	typedef vector<CustomMenuItem*> MenuList;
	typedef MenuList::const_iterator MenuIter;   

	typedef map<int, string> URLList;
	

	CustomMenuManager(void);
	~CustomMenuManager(void);

    const MenuList& getMenuList() {  return m_menuList; }

	void load();

	string GetUrlByID(int id);

	GETSET(string, _title, Title);


private:

	size_t GetData(string const& url, string& data);
	void clearList();

	MenuList m_menuList;
	URLList m_urlList;

	// SettingsManagerListener
	// Load by hand now.
	//virtual void on(SettingsManagerListener::Load, SimpleXML& xml) throw() {
	//	load(xml);
	//}
	//void load(SimpleXML& aXml);


	void ProcessXMLSubMenu(SimpleXML& xml, int& i);
};

#endif // CUSTOM_MENU_MANAGER_H